package medium;

/**
 * @author admin
 * 11. 盛最多水的容器
 * 解题思路：双指针思想，起点和终点各一个指针，每次移动较小的那个
 */
public class LeeCode11 {

    public int maxArea(int[] height) {
        int l = 0;
        int r = height.length - 1;
        int res = 0;
        int temp;
        while(l < r){
            temp = Math.min(height[l],height[r])*(r-l);
            res = Math.max(res,temp);

            if (height[l] <= height[r]){
                l++;
            }else{
                r--;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(new LeeCode11().maxArea(new int[]{1,1}));
    }

}
